package com.geekaca.d06;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class TestCollections {
    public static void main(String[] args) {
//        List<String> names = new ArrayList<>();
//        names.add("张三");
//        names.add("Tom");
//        names.add("Jack");
//        names.add("Jerry");
//
//        Collections.addAll(names, "c楚留香", "z张无忌", "l陆小凤", "Test", "Java");
//        System.out.println(names);
//        // 打乱顺序
//        Collections.shuffle(names);
//        System.out.println(names);
//        // 排序
//        Collections.sort(names, (o1, o2) -> o1.compareTo(o2));
//        System.out.println(names);
//
//        Collections.sort(names, (o1, o2) -> o2.compareTo(o1));
//        System.out.println(names);
        testCompare();

    }

    public  static void testCompare(){
        List<Apple> apples = new ArrayList<>();
        apples.add(new Apple("红富士","红色",9.9,500));
        apples.add(new Apple("青苹果","绿色",15.9,300));
        apples.add(new Apple("绿苹果","青色",29.9,400));
        apples.add(new Apple("黄苹果","黄色",9.8,500));

        Collections.sort(apples);
        System.out.println(apples);
    }


}
